CC=gcc

ROOT=.
PROJDIR=$(ROOT)/../..
OBJDIR=$(PROJDIR)/obj
SRCDIR=$(ROOT)


SRCS=$(wildcard $(SRCDIR)/*.S)
tmps=$(notdir $(SRCS))
TMPS=$(patsubst %.S,$(SRCDIR)/%.s,$(tmps))
OBJS=$(patsubst %.s,$(OBJDIR)/%.o,$(TMPS))

ASFLAGS=--64

ifeq ($(DEBUG), ON)
ASFLAGS+=-g
endif
INCS=-I$(PROJDIR)/include


.PHONY: all clean 

all:$(OBJS)


$(OBJS):$(TMPS)
	as $(ASFLAGS)  $< -o $@

$(TMPS):$(SRCS)
	gcc -E $(INCS) -o $@ $<

clean:
	rm -f $(OBJS) $(TMPS)
